package com.inhim.pjhim.adapter;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Handler;
import android.support.constraint.ConstraintLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.inhim.pjhim.R;
import com.inhim.pjhim.activity.IssueInfoActivity;
import com.inhim.pjhim.activity.TypeListActivity;
import com.inhim.pjhim.entity.HelpListEntity;
import com.inhim.pjhim.entity.ReaderTypeList;
import com.inhim.pjhim.utils.ImageLoaderUtils;
import com.inhim.pjhim.view.CustomRoundAngleImageView;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

import java.io.Serializable;

public class HelpListAdapter extends RecyclerArrayAdapter<HelpListEntity.List> {

    private Activity context;
    PersonViewHolder viewHolder;
    public HelpListAdapter(Activity context) {
        super(context);
        this.context=context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        View mView = null;
        if (mView == null) {
            mView = LayoutInflater.from(context).inflate(R.layout.item_help_list, null);
            viewHolder = new PersonViewHolder(mView);
        } else {
            viewHolder = (PersonViewHolder) mView.getTag();
        }
        return viewHolder;
    }

    public class PersonViewHolder extends BaseViewHolder<HelpListEntity.List> {
        public TextView tv_name;
        public PersonViewHolder(View itemView) {
            super(itemView);
            tv_name = getView(R.id.tv_name);
        }

        @Override
        public void setData(HelpListEntity.List data) {
            super.setData(data);
            tv_name.setText(data.getQuery());
            if(viewHolder!=null){
                viewHolder.itemView.setOnClickListener(v -> {
                    Intent intent=new Intent(context, IssueInfoActivity.class);
                    intent.putExtra("CommonProblemId",data.getCommonProblemId());
                    intent.putExtra("Query",data.getQuery());
                    context.startActivity(intent);
                });
            }
        }

    }

}
